package com.ruoyi.consultation.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.consultation.domain.LabConsultationInfo;
import com.ruoyi.consultation.service.ILabConsultationInfoService;

/**
 * 信息咨询Controller
 * 
 * @author winner pan
 * @date 2022-03-28
 */
@RestController
@RequestMapping("/consultation/content")
public class LabConsultationInfoController extends BaseController {
	@Autowired
	private ILabConsultationInfoService labConsultationInfoService;

	/**
	 * 查询信息咨询列表.
	 * 公共资源，查询不设权限
	 */
	//@PreAuthorize("@ss.hasPermi('consultation:content:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabConsultationInfo labConsultationInfo) {
		startPage();
		List<LabConsultationInfo> list = labConsultationInfoService.selectLabConsultationInfoList(labConsultationInfo);
		return getDataTable(list);
	}

	/**
	 * 导出信息咨询列表
	 */
	// @PreAuthorize("@ss.hasPermi('consultation:content:export')")
	/*@Log(title = "信息咨询", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(LabConsultationInfo labConsultationInfo) {
		List<LabConsultationInfo> list = labConsultationInfoService.selectLabConsultationInfoList(labConsultationInfo);
		ExcelUtil<LabConsultationInfo> util = new ExcelUtil<LabConsultationInfo>(LabConsultationInfo.class);
		return util.exportExcel(list, "content");
	}*/

	/**
	 * 获取信息咨询详细信息
	 * 公共资源，查询不设权限
	 */
	//@PreAuthorize("@ss.hasPermi('consultation:content:query')")
	@GetMapping(value = "/{consultationId}")
	public AjaxResult getInfo(@PathVariable("consultationId") Long consultationId) {
		return AjaxResult.success(labConsultationInfoService.selectLabConsultationInfoById(consultationId));
	}

	/**
	 * 新增信息咨询
	 */
	@PreAuthorize("@ss.hasPermi('consultation:content:edit')")
	@Log(title = "信息咨询", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabConsultationInfo labConsultationInfo) {
		return toAjax(labConsultationInfoService.insertLabConsultationInfo(labConsultationInfo));
	}

	/**
	 * 修改信息咨询
	 */
	@PreAuthorize("@ss.hasPermi('consultation:content:edit')")
	@Log(title = "信息咨询", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabConsultationInfo labConsultationInfo) {
		return toAjax(labConsultationInfoService.updateLabConsultationInfo(labConsultationInfo));
	}

	/**
	 * 删除信息咨询
	 */
	@PreAuthorize("@ss.hasPermi('consultation:content:edit')")
	@Log(title = "信息咨询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{consultationIds}")
	public AjaxResult remove(@PathVariable Long[] consultationIds) {
		return toAjax(labConsultationInfoService.deleteLabConsultationInfoByIds(consultationIds));
	}
}
